aisles_summary |>
filter(n > 10000) |>
mutate(aisle = fct_reorder(aisle, n)) |>
mutate(hover = paste0("Aisle: ", aisle, "<br>Orders: ", n)) |>
plot_ly(
x = ~n, y = ~aisle, type = "bar", orientation = "h",
text = ~hover, hoverinfo = "text",
color = ~aisle, colors = "viridis", showlegend = FALSE ) |>
layout(
title = "Number of Items Ordered by Aisle (>10,000 orders)",
xaxis = list(title = "Number of Items Ordered"),
yaxis = list(title = "Aisle")
)
——————————————————————-_
instacart |>
filter(department %in% c("produce", "dairy eggs", "snacks")) |>
count(department, order_hour_of_day, name = "orders") |>
plot_ly(
x = ~order_hour_of_day,
y = ~orders,
color = ~department,
type = "scatter",
mode = "lines+markers",
colors = c("#4E79A7", "#F28E2B", "#E15"))|>
layout(
title = "Ordering Trends Throughout the Day",
xaxis = list(title = "Hour of Day (0–23)"),
yaxis = list(title = "Number of Orders"),
legend = list(orientation = "v"))
instacart |>
filter(department %in% c("produce", "dairy eggs", "snacks"))|> mutate(department =fct_reorder(department,add_to_cart_order)) |>
plot_ly(
x = ~department,
y = ~add_to_cart_order,
color = ~department,
type = "violin",
colors = c("#4E79A7", "#F28E2B", "#E15"),
box = list(visible = TRUE),
meanline = list(visible = TRUE),
opacity = 0.8
) |>
layout(
title = "Distribution of Add-to-Cart Order by Department",
xaxis = list(title = "Department"),
yaxis = list(title = "Add-to-Cart Order")
)